package com.buaa.hyf.adapter;

import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.buaa.hyf.activity.R;
import com.buaa.hyf.util.Globals;
import com.buaa.hyf.util.ImageUtil;

import java.util.List;
import java.util.Map;

/**
 * Created by Jeson on 2016/4/23.
 */
public class GrideAdapter extends BaseAdapter {

    private Context ctx;
    private List<Map<String,Object>> values;

    public GrideAdapter(Context ctx, List<Map<String,Object>> values) {
        this.ctx = ctx;
        this.values = values;
    }

    @Override
    public int getCount() {
        return 0;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if(convertView==null){
            convertView = LayoutInflater.from(ctx).inflate(R.layout.activity_gridview,null);
            convertView.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Globals.SCREEN_HEIGHT/6));
        }

        Map<String,Object> map = values.get(position);
        TextView stage = (TextView) convertView.findViewById(R.id.stage);
        stage.setText(map.get("stage").toString());
        if((boolean)map.get("overFlag")){
            stage.setBackgroundDrawable(new BitmapDrawable(ctx.getResources(), ImageUtil.getCanSelect()));
        }else{
            stage.setBackgroundDrawable(new BitmapDrawable(ctx.getResources(),ImageUtil.getNoSelect()));
        }
        return convertView;
    }
}
